package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class OOSDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("person2.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        Person p=new Person();
        p.setName("张三");
        p.setAge(20);
        p.setGender("男");
        p.setOtherInfo(new String[]{"北京","single","black"});
        oos.writeObject(p);
        System.out.println("写入成功");
        oos.close();
        fos.close();
    }
}
